import { Growl } from './grow';
import { LoadMask } from './loadmask';
import { RouteModel } from './../viewBaseService';
import { ChangeDetectorRef } from '@angular/core';
import { MessageBoxService } from './../messageBox/messageBoxService';
import { Message } from './../messageBox/confirmMessage';
import { MessageBoxContainer } from './../messageBox/MessageBoxContainer';
import { Confirm } from './confirm';
import { HostBinding } from '@angular/core';
import { Component, ElementRef, AfterViewInit, OnDestroy, OnChanges, Input, Output, SimpleChange, EventEmitter } from '@angular/core';
import { MessageResult } from './messageBox';
import { ViewBaseService } from "../viewBaseService";

@Component({
    selector: 'common-components',
    styleUrls: [
        './common-components.scss'
    ],
    template: `
        <div class="common-components-container" >
            <load-mask></load-mask>
            <confirm [title]="Title" [content]="Content" [visible]="Visible" (onResult)="onResult($event)"></confirm>
            <growl [value]="GrowlMessage"></growl>
        </div>
    `,
})
export class CommonComponents implements MessageBoxContainer {
    Title: string;
    Content: string;
    Visible: boolean;
    showOK: boolean = true;
    showCancel: boolean = true;
    showIgnore: boolean = false;
    GrowlMessage: Message[];
    isOnLoading: boolean = false;
    onResult;
    constructor(public changeDetectorRef: ChangeDetectorRef) {
        MessageBoxService.current.Regist(this);
    }
    detectChanges() {
        this.changeDetectorRef.detectChanges();
    }
}


export class CommonComponentsService extends ViewBaseService {
    static current = new CommonComponentsService();
    components = [Confirm,  Growl, LoadMask];
    route = {
        path:"",
        component:CommonComponents
    }
}